package com.boarsoft.boar.entity;

import java.io.Serializable;

/**
 * APP实例监息
 */
public class AppInst implements Serializable {
	private static final long serialVersionUID = 5505646907018550546L;

	public static final short STATUS_DISABLED = 0; // 已停用（卸载）
	public static final short STATUS_MISSING = 1;// 未部署
	public static final short STATUS_STOPPED = 2;// 已实际部署但应用处于未启动状态
	public static final short STATUS_DEPLOYING = 3;// 正在部署状态
	public static final short STATUS_STARTING = 4; // 启动过程中
	public static final short STATUS_RUNNING = 5;// 已实际部署且应用处于启动运行状态
	public static final short STATUS_STOPPING = 6; // 停机过程中
	public static final short STATUS_FAILED = 7; // 启动失败或通讯失败
	public static final short STATUS_UNKNOWN = 8; // 未知

	/** */
	private String id;
	/** */
	private String serverId;
	/** */
	private String appId;
	/** */
	private int no;
	/** */
	private String env;
	/** */
	private String group;
	/** k8s cluster */
	private String cluster;
	/** */
	private String zone;
	/** */
	private short status = STATUS_DISABLED;
	/** 冗余IP，而且一个节点可能有多个IP */
	private String ip;
	/** 本应用实例使用了哪个端口（主端口） */
	private int port = 2187;

	/** 应用实例的根目录 目前给部署路径配置默认值 */
	private String deployPath = "/home/app/deploy/";
	/** 冗余自应用监息中的部署用临时目录 */
	@Deprecated
	private String tempPath = "/home/app/temp";
	/**
	 * 用来识别某个应用的某个实例的（当前应用范围内）唯一ID<br>
	 * 使用容器时，建议取容器实例ID
	 */
	private String key;
	/** 关联服务器用户 */
	private String user;

	/** fetch join AppInfo */
	private transient AppInfo app;
	/** fetch join server */
	private transient ServerInfo server;

	public String toString() {
		return new StringBuilder().append(appId).append("/")//
				.append(ip).append(":").append(port).toString();
	}

	public String getAddr() {
		return new StringBuilder().append(ip).append(":").append(port).toString();
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public String getDeployPath() {
		return deployPath;
	}

	public void setDeployPath(String deployPath) {
		this.deployPath = deployPath;
	}

	public String getServerId() {
		return serverId;
	}

	public void setServerId(String serverId) {
		this.serverId = serverId;
	}

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public short getStatus() {
		return status;
	}

	public void setStatus(short status) {
		this.status = status;
	}

	public AppInfo getApp() {
		return app;
	}

	public void setApp(AppInfo app) {
		this.app = app;
	}

	public ServerInfo getServer() {
		return server;
	}

	public void setServer(ServerInfo server) {
		this.server = server;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public String getTempPath() {
		return tempPath;
	}

	public void setTempPath(String tempPath) {
		this.tempPath = tempPath;
	}

	public String getEnv() {
		return env;
	}

	public void setEnv(String env) {
		this.env = env;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getGroup() {
		return group;
	}

	public void setGroup(String group) {
		this.group = group;
	}

	public String getZone() {
		return zone;
	}

	public void setZone(String zone) {
		this.zone = zone;
	}

	public String getCluster() {
		return cluster;
	}

	public void setCluster(String cluster) {
		this.cluster = cluster;
	}

}